﻿using StoryTeller.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoryTeller.Infrastructure.DataAccess.Parser
{
    public static class ChapterParser
    {
        public static Chapter ParseEntityToDomain(this EChapter entity)
        {
            Chapter ch = new Chapter();

            ch.Contributions = entity.Contributions == null ? null : entity.Contributions.Select(c => c.ParseEntityToDomain()).ToList();
            ch.CreationDate = entity.CreationDate;
            ch.Description = entity.Description;
            ch.Id = entity.Id;
            ch.LastUpdate = entity.LastUpdate;
            ch.Title = entity.Title;

            return ch;
        }

        public static EChapter ParseDomainToEntity(this Chapter domain)
        {
            EChapter ch = new EChapter();

            ch.Contributions = domain.Contributions == null ? null : domain.Contributions.Select(c => c.ParseDomainToEntity()).ToList();
            ch.CreationDate = domain.CreationDate;
            ch.Description = domain.Description;
            ch.Id = domain.Id;
            ch.LastUpdate = domain.LastUpdate;
            ch.Title = domain.Title;

            return ch;
        }
    }
}
